package com.tang.sharding.schedule.task;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

/**
 * @author Tang
 * @classname AbstractRunnableTask
 * @description [  ]
 * @date 2021/8/1 17:00
 */
@Slf4j
public abstract class AbstractRunnableTask implements Runnable{

    @Getter
    private String taskId;

    /**
     * 任务描述信息
     */
    @Getter
    @Setter
    private String describe;

    public AbstractRunnableTask(String taskId) {
        this.taskId = taskId;
    }

    @Override
    public void run() {
        log.info(Thread.currentThread().getName() + "-任务开始时间..." + LocalDateTime.now());
        doWork();
        log.info(Thread.currentThread().getName() + "-任务结束时间..." + LocalDateTime.now());
    }

    /**
     * 具体工作
     */
    protected abstract void doWork();
}